﻿using AutoMapper;
using ERPSystem.Common.Domains.ReturnNotice;
using ERPSystem.Common.DTO;
using ERPSystem.Enum.CommonErrorCodes;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SalesManagementWrite.API.SalesManagementWrites.ReturnNotices;
using SqlSugar;
using Yitter.IdGenerator;

namespace SalesManagementWrite.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReturnNoticessController : ControllerBase
    {
        private readonly IMediator _mediator;

        public ReturnNoticessController(IMediator mediator)
        {
            _mediator = mediator;
        }


        /// <summary>
        /// 退货通知单添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> AddReturnNoticeandle(ReturnNoticeCreateCommon request, CancellationToken cancellationToken)
        {
            request.ThSerialnumber = YitIdHelper.NextId().ToString();
            request.ReturnNumber = "THDD" + YitIdHelper.NextId().ToString();
            var result = await _mediator.Send(request);
            return result;
        }
    }
}
